home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-16 | 1.6 KB | 45 lines | [TEXT/MPS ] |
- #----------------------------------------------------------------------------------------------------------------------------------------------------
- # MyOpen
- # MPW Shell Script
- # Written by Gina Cherry • August 16, 1991
- # Copyright: © 1991 by Apple Computer, Inc., all rights reserved.
- #
- # Usage: MyOpen [file]
- #
- # Function:
- # MyOpen will look through a predefined list of paths for the file specified on the command line.
- # The list of paths is specified in the shell variable openList, which should be initialized and
- # exported in the UserStartup file. If a file is not specifed on the command line, MyOpen will
- # prompt the user for a file to open.
- #----------------------------------------------------------------------------------------------------------------------------------------------------
-
- # Make sure there's no more than one parameter.
- If {#} > 1
- Echo "### Usage: {0} [file]" >> Dev:StdErr
- Exit 1
- End
-
- # Don't exit on error.
- Set Exit 0
-
- # If a parameter is given, set file to the parameter.
- If {#} == 1
- Set file "{1}"
- # Otherwise, prompt the user for a file to open.
- Else
- Set file "`Request "Open what file?"`"
- Exit If "{file}" == ""
- End
-
- # Loop through paths in openList
- For path in {openList}
- # Try to open file using current path.
- Open "{path}{file}" ≥ Dev:Null
- # If open succeeds, exit script.
- Exit If {Status} == 0
- End
-
- # If the execution of the script reaches this point, the file does not exist in any of the directories
- # defined in openList. In that case, write error message and exit script with status 2.
- Echo "### {0}: File {file} not found." >> Dev:StdErr
- Exit 2